package a06;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyConfig1 {


    @Autowired
    public void method(ApplicationContext context) {
        System.out.println("*******@Autowired方法，applicationContext: " + context);
    }


    /**
     * 会导致上面的@Autowired失效
     * @return
     */
    @Bean
    public BeanFactoryPostProcessor processor1() {
        return new BeanFactoryPostProcessor() {
            @Override
            public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
                System.out.println("自定义后置处理器....");
            }
        };
    }


}
